package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.hibernate.mapping.Array;

import play.db.jpa.Model;

@Entity
public class User extends Model {
	@Column(unique = true) 
	public String facebookID;
	private String facebookName;
	private String facebookPictureUrl;
	public User(String facebookID) {
	  this.facebookID = facebookID;
    }
	
	public User(String facebookID , String faceBookName, String facebookPictureUrl){
		  this.facebookID = facebookID;
		  this.facebookName = faceBookName;
		  this.facebookPictureUrl = facebookPictureUrl;
		 
	}

	
	public  UserCity  addCityOfUser(UserCity userCity){
		userCity.setUserId(this.getId());
	   return 	userCity.save();
	}
	
	
	public String getFacebookID() {
  	return facebookID;
  }

	public void setFacebookID(String facebookID) {
  	this.facebookID = facebookID;
  }
	
	public static User getByFacebookID(String facebookID) {
		return User.find("facebookID = ? ", facebookID).first();
	}

	public List<UserCity> getCities() {
		List<UserCity> userCities = null;
		userCities = UserCity.find("userId = ?", this.getId()).fetch();
		return userCities;
	}

	

	public String getFacebookPictureUrl() {
		return facebookPictureUrl;
	}

	public void setFacebookPictureUrl(String facebookPictureUrl) {
		this.facebookPictureUrl = facebookPictureUrl;
	}

	public String getFacebookName() {
		return facebookName;
	}

	public void setFacebookName(String facebookName) {
		this.facebookName = facebookName;
	}

	public List<Comment> getComments() {
		return null;
	}

	

	public List<PlaceRanking> getRanks() {
		return null;
	}

	
}
